﻿using System;
using System.IO;

using WebDavProcessor.Resources;

namespace WebDavProcessor.Interfaces
{
    public interface IWebDavIOProvider : IWebDavResourceProvider
    {
        /// <summary>
        /// Reads a whole resource. Returns anything (or nothing) for collections.
        /// </summary>
        /// <param name="resourcePath">The resource identificator.</param>
        /// <returns>The stream that contains the resource data (WebDavStreamResource) or the empty resource (WebDavResource) with the error code.</returns>
        WebDavResource Read(string resourcePath);
        /// <summary>
        /// Reads a resource at the given offset. Returns anything (or nothing) for collections.
        /// </summary>
        /// <param name="resourcePath">The resource identificator.</param>
        /// <param name="offset">The begining of the requested data.</param>
        /// <param name="count">The number of bytes of the requested data.</param>
        /// <returns>The stream that contains the resource data (WebDavStreamResource) or the empty resource (WebDavResource) with the error code.</returns>
        WebDavResource Read(string resourcePath, int offset, int count);
        /// <summary>
        /// Writes a new resource. Overides permanently. Must fail with the 409 error code, if the parent collection doesn't exist. May fail with the 405 error code, if the resource is a collection.
        /// </summary>
        /// <param name="resourcePath">The resource identificator.</param>
        /// <param name="data">The resource stream.</param>
        /// <returns>The empty resource (WebDavResource) with the status code.</returns>
        WebDavResource Write(string resourcePath, Stream data);
        /// <summary>
        /// Deletes an existing resource. The depth for this operation is the only infinity for collections. Can return the multistatus response, if the operation failed partially. May return the 4xx error code, if the operation failed completely.
        /// </summary>
        /// <param name="resourcePath">The resource identificator.</param>
        /// <returns>The empty resource (WebDavResource) with the status code or the multistatus resource (WebDavResourceCollection) for collections.</returns>
        WebDavResource Delete(string resourcePath);
        WebDavResource CreateCollection(string resourcePath);
        WebDavResource Copy(string resourcePath, string destinationPath);
        WebDavResource Move(string resourcePath, string destinationPath);
    }
}
